package com.timber.util;

import javax.swing.*;
import java.awt.*;



public class SearchableComboBoxEditor extends UpperCaseField implements ComboBoxEditor
{

    private boolean display_description = false;
    public void setDisplayDescription(boolean b){display_description = b;}
    public boolean getDisplayDescription(){ return display_description;}

    public Component getEditorComponent(){return this;}
    public Object getItem()
    {
      /*if (this.getText().length() < 1)
        return null;
      */
      return this.getText();
    }



    public void setItem(Object anObject)
    {

      if (anObject == null)
      {
        this.setText("");
        return;
      }
      try
      {
        SLDataObject slDataObject = (SLDataObject)anObject;
        if(display_description)
          this.setText(slDataObject.getDescr());
        else
          this.setText(slDataObject.listString());
      }
      catch (ClassCastException e)
      {
        this.setText(anObject.toString());
      }


    }




}
